import { IPSModelSortable } from '../../ipsmodel-sortable';
import { IPSDataEntity } from '../ipsdata-entity';
import { IPSDEAction } from '../action/ipsdeaction';
import { IPSDEDataSync } from './ipsdedata-sync';
import { IPSDEDataSet } from '../ds/ipsdedata-set';
import { IPSSysDataSyncAgent } from '../../res/ipssys-data-sync-agent';
import { IPSSysSFPlugin } from '../../res/ipssys-sfplugin';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEDataSyncImpl extends PSModelObjectImpl implements IPSDEDataSync, IPSModelSortable {
  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get eventType(): 1 | 2 | 4 | 256 | 512 {
    return this.M.eventType;
  }

  get extendMode(): 0 | 2 {
    return this.M.extendMode != null ? this.M.extendMode : 0;
  }

  protected importpsdeaction: IPSDEAction | null = null;

  getImportPSDEAction(): IPSDEAction | null {
    if (this.importpsdeaction != null) return this.importpsdeaction;
    const value = this.M.getImportPSDEAction;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.importpsdeaction = ipsdataentity.findPSDEAction(value);
    }
    return this.importpsdeaction;
  }

  get importPSDEAction(): IPSDEAction | null {
    return this.getImportPSDEAction();
  }

  getImportPSDEActionMust(): IPSDEAction {
    const value = this.getImportPSDEAction();
    if (value == null) {
      throw new Error('未指定导入实体行为');
    }
    return value;
  }

  protected inpsdedataset: IPSDEDataSet | null = null;

  getInPSDEDataSet(): IPSDEDataSet | null {
    if (this.inpsdedataset != null) return this.inpsdedataset;
    const value = this.M.getInPSDEDataSet;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.inpsdedataset = ipsdataentity.findPSDEDataSet(value);
    }
    return this.inpsdedataset;
  }

  get inPSDEDataSet(): IPSDEDataSet | null {
    return this.getInPSDEDataSet();
  }

  getInPSDEDataSetMust(): IPSDEDataSet {
    const value = this.getInPSDEDataSet();
    if (value == null) {
      throw new Error('未指定输入数据集合');
    }
    return value;
  }

  protected inpssysdatasyncagent: IPSSysDataSyncAgent | null = null;

  getInPSSysDataSyncAgent(): IPSSysDataSyncAgent | null {
    if (this.inpssysdatasyncagent != null) return this.inpssysdatasyncagent;
    const value = this.M.getInPSSysDataSyncAgent;
    if (value == null) {
      return null;
    }
    this.inpssysdatasyncagent = this.getPSModel4('res.IPSSysDataSyncAgent', value, 'getInPSSysDataSyncAgent') as IPSSysDataSyncAgent;
    return this.inpssysdatasyncagent;
  }

  get inPSSysDataSyncAgent(): IPSSysDataSyncAgent | null {
    return this.getInPSSysDataSyncAgent();
  }

  getInPSSysDataSyncAgentMust(): IPSSysDataSyncAgent {
    const value = this.getInPSSysDataSyncAgent();
    if (value == null) {
      throw new Error('未指定输入系统数据同步代理对象');
    }
    return value;
  }

  get inScriptCode(): string {
    return this.M.inScriptCode;
  }

  protected intestpsdeaction: IPSDEAction | null = null;

  getInTestPSDEAction(): IPSDEAction | null {
    if (this.intestpsdeaction != null) return this.intestpsdeaction;
    const value = this.M.getInTestPSDEAction;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.intestpsdeaction = ipsdataentity.findPSDEAction(value);
    }
    return this.intestpsdeaction;
  }

  get inTestPSDEAction(): IPSDEAction | null {
    return this.getInTestPSDEAction();
  }

  getInTestPSDEActionMust(): IPSDEAction {
    const value = this.getInTestPSDEAction();
    if (value == null) {
      throw new Error('未指定输入判断实体行为');
    }
    return value;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  get orderValue(): number {
    return this.M.orderValue != null ? this.M.orderValue : 99999;
  }

  protected outpsdedataset: IPSDEDataSet | null = null;

  getOutPSDEDataSet(): IPSDEDataSet | null {
    if (this.outpsdedataset != null) return this.outpsdedataset;
    const value = this.M.getOutPSDEDataSet;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.outpsdedataset = ipsdataentity.findPSDEDataSet(value);
    }
    return this.outpsdedataset;
  }

  get outPSDEDataSet(): IPSDEDataSet | null {
    return this.getOutPSDEDataSet();
  }

  getOutPSDEDataSetMust(): IPSDEDataSet {
    const value = this.getOutPSDEDataSet();
    if (value == null) {
      throw new Error('未指定输出数据集合');
    }
    return value;
  }

  protected outpssysdatasyncagent: IPSSysDataSyncAgent | null = null;

  getOutPSSysDataSyncAgent(): IPSSysDataSyncAgent | null {
    if (this.outpssysdatasyncagent != null) return this.outpssysdatasyncagent;
    const value = this.M.getOutPSSysDataSyncAgent;
    if (value == null) {
      return null;
    }
    this.outpssysdatasyncagent = this.getPSModel4('res.IPSSysDataSyncAgent', value, 'getOutPSSysDataSyncAgent') as IPSSysDataSyncAgent;
    return this.outpssysdatasyncagent;
  }

  get outPSSysDataSyncAgent(): IPSSysDataSyncAgent | null {
    return this.getOutPSSysDataSyncAgent();
  }

  getOutPSSysDataSyncAgentMust(): IPSSysDataSyncAgent {
    const value = this.getOutPSSysDataSyncAgent();
    if (value == null) {
      throw new Error('未指定输出系统数据同步代理对象');
    }
    return value;
  }

  get outScriptCode(): string {
    return this.M.outScriptCode;
  }

  protected outtestpsdeaction: IPSDEAction | null = null;

  getOutTestPSDEAction(): IPSDEAction | null {
    if (this.outtestpsdeaction != null) return this.outtestpsdeaction;
    const value = this.M.getOutTestPSDEAction;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.outtestpsdeaction = ipsdataentity.findPSDEAction(value);
    }
    return this.outtestpsdeaction;
  }

  get outTestPSDEAction(): IPSDEAction | null {
    return this.getOutTestPSDEAction();
  }

  getOutTestPSDEActionMust(): IPSDEAction {
    const value = this.getOutTestPSDEAction();
    if (value == null) {
      throw new Error('未指定输出判断实体行为');
    }
    return value;
  }

  get outputMode(): 1 | 2 {
    return this.M.outputMode != null ? this.M.outputMode : 1;
  }

  protected pssyssfplugin: IPSSysSFPlugin | null = null;

  getPSSysSFPlugin(): IPSSysSFPlugin | null {
    if (this.pssyssfplugin != null) return this.pssyssfplugin;
    const value = this.M.getPSSysSFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyssfplugin = this.getPSModel4('res.IPSSysSFPlugin', value, 'getPSSysSFPlugin') as IPSSysSFPlugin;
    return this.pssyssfplugin;
  }

  get psSysSFPlugin(): IPSSysSFPlugin | null {
    return this.getPSSysSFPlugin();
  }

  getPSSysSFPluginMust(): IPSSysSFPlugin {
    const value = this.getPSSysSFPlugin();
    if (value == null) {
      throw new Error('未指定后台扩展插件');
    }
    return value;
  }

  get syncDir(): 'IN' | 'OUT' {
    return this.M.syncDir;
  }

  get syncTag(): string {
    return this.M.syncTag;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get exportFull(): boolean {
    return this.M.exportFull;
  }

  get inCustomCode(): boolean {
    return this.M.inCustomCode != null ? this.M.inCustomCode : false;
  }

  get inMode(): boolean {
    return this.M.inMode;
  }

  get outCustomCode(): boolean {
    return this.M.outCustomCode != null ? this.M.outCustomCode : false;
  }

  get valid(): boolean {
    return this.M.valid != null ? this.M.valid : true;
  }

  get cls(): string {
    return 'PSDEDataSyncImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'IPSModelSortable' || cls == 'dataentity.datasync.IPSDEDataSync') return true;
    return super.instanceof(cls);
  }
}
